<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        /****    简单类型      ****/
        //string
        var str = '这是字符串';
        console.log(typeof str);//string
        //number
        var num = 20;
        console.log(typeof num);//number;
        //布尔
        var bool = true;
        console.log(typeof bool);//boolean
        //undefind
        var a;
        console.log(typeof a);//undefind
        //null
        var b = null;
        console.log(typeof b);//null | object



        /*****************复杂数据类型***************************/
        // 对象
        var obj = {
            name: '老周',
            sayHi: function () {
                console.log('hi'); //object
            }
        }
        console.log(typeof obj);//object
        obj.sayHi();


        //数组
        var arr = [1, 24, 30];
        console.log(typeof arr);//object



        //date时间对象
        var date = new Date();
        console.log(typeof date);//object




        var fun = function () {
        }
        console.log(typeof fun);//function


        //结论：复杂数据类型 通过操作符 typeof 操作得到 的 类型为object
        //但是 function 这个复杂数据类型除外，它得到的类型为function

        //简单数据类型的包装

        var str1 = str.substr(1);
        console.log(str1);

    </script>
</body>

</html>